import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutterapp/src/page/login/login_page.dart';
import 'package:flutterapp/src/utils/navigator_utils.dart';

class MineNoLoginPage extends StatefulWidget {
  final StreamController loginStreamController;
  MineNoLoginPage(this.loginStreamController);
  @override
  _MineNoLoginPageState createState() => _MineNoLoginPageState();
}

class _MineNoLoginPageState extends State<MineNoLoginPage> {
  bool isDown = false;
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Color(0xffcddeec),
      child: Stack(
        alignment: Alignment.center,
        children: [
          GestureDetector(
            onTapDown: (TapDownDetails details) {
              setState(() {
                isDown = true;
              });
            },
            onTapCancel: () {
              setState(() {
                isDown = false;
              });
            },
            onTap: () {
              setState(() {
                isDown = false;
              });
              NavigatorUtils.pushPageByFade(
                  startMills: 1200,
                  context: context,
                  targetPage: LoginPage(widget.loginStreamController));
            },
            child: buildHero(),
          ),
        ],
      ),
    );
  }

// 构建Hero动画
  buildHero() {
    return Hero(
      tag: "logo",
      child: Material(
        color: Colors.transparent,
        child: buildContainer(),
      ),
    );
  }
  // 构建内容

  buildContainer() {
    return Container(
      alignment: Alignment.center,
      width: 76,
      height: 76,
      decoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(43)),
          color: Colors.redAccent,
          // 按下的阴影
          boxShadow: isDown
              ? [
                  BoxShadow(
                      offset: Offset(3, 4),
                      color: Colors.black,
                      blurRadius: 13),
                ]
              : null),
      child: Text(
        "登录",
        style: TextStyle(
            fontSize: 16, fontWeight: FontWeight.w500, color: Colors.white),
      ),
    );
  }
}
